package com.neolix.watch.adapter;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.view.ViewGroup;

import com.neolix.watch.view.BluetoothDeviceItemView;

import java.util.List;

import static com.google.common.collect.Lists.newArrayList;

public class BluetoothListAdapter extends NeolixBaseAdapter<BluetoothDeviceItemView> {
    private List<BluetoothDevice> items = newArrayList();
    private Context context;

    public BluetoothListAdapter(Context context) {
        this.context = context;
    }

    public void setData(List<BluetoothDevice> items) {
        this.items = items;
        notifyDataSetChanged();
    }

    @Override
    protected void updateView(BluetoothDeviceItemView view, int position) {
        view.setModel(items.get(position));
    }

    @Override
    protected BluetoothDeviceItemView buildView(ViewGroup parent) {
        BluetoothDeviceItemView deviceItemView = new BluetoothDeviceItemView(context);
        return deviceItemView;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public BluetoothDevice getItem(int i) {
        return items.get(i);
    }
}
